<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
include "functions.php";
if (isset($_SESSION['lang']))
    require_once "./language_files/main_" . $_SESSION['lang'] . ".php";
else
    require_once "./language_files/main_en.php";

if (!isset($_SESSION['member_id'])) {
    echo "<script type='text/javascript'>top.window.location='index.php';</script>";
    exit();
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <?php
        // Author: Mohamed Abdel Hakim
        ?>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <link rel="shortcut icon" type="image/x-icon" href="menu icons/favicon.ico"/>
        <link href="style3.css" rel="stylesheet" type="text/css" />
        <title><?php echo $lang['title']; ?></title>
    </head>
    <body>
        <?php
        if (count($_GET) > 0) {
            $arrKeys = array_keys($_GET);
            $iRequestLength = count($_GET);
            for ($i = 0; $i < $iRequestLength; $i++) {
                $_SESSION['tmp'][$arrKeys[$i]] = $_GET[$arrKeys[$i]];
            }
            echo "<script type='text/javascript'>top.window.location='main.php';</script>";
            exit();
        }
        if (isset($_SESSION['tmp'])) {
            $iTmpLength = count($_SESSION['tmp']);
            $arrTmpKeys = array_keys($_SESSION['tmp']);
            for ($i = 0; $i < $iTmpLength; $i++) {
                if ($arrTmpKeys[$i] == "page") {
                    echo "<input type='hidden' class='page' name='{$arrTmpKeys[$i]}' value='{$_SESSION['tmp'][$arrTmpKeys[$i]]}'/>";
                } else {
                    echo "<input type='hidden' class='parameter' name='{$arrTmpKeys[$i]}' value='{$_SESSION['tmp'][$arrTmpKeys[$i]]}'/>";
                }
            }
            unset($_SESSION['tmp']);
        }
        if (isset($_GET['new'])) {// if it is the user's first logging in a welcoming message is displayed
            echo "<script type='text/javascript'>
                display_alert('welcome to confO!');
            </script>";
        }
        ?>
        <table class="news_bar">
            <tr>
                <td><div class="float_left" id="bt" title="Home" style="cursor: pointer;">
                        <img src="logo-1038766.png" alt="ConfO logo"  />
                    </div></td>
                 <td></td> <td></td><td></td><td></td><td></td><td></td>
                <td style="text-align: center;"><label id="server_time"></label></td>
                <td> <div class="logout">
                        <?php
                        $rsProfPic = rsSelect("profilepic_path", "member", array("member_id=", $_SESSION['member_id']));
                        if (is_string($rsProfPic)) {
                            echo $rsProfPic . __LINE__;
                            exit();
                        }
                        if (mysql_num_rows($rsProfPic) > 0) {
                            while ($row = mysql_fetch_assoc($rsProfPic)) {
                                $image = $row['profilepic_path'];
                                echo "<div class='float_left'><img src='$image' alt='/profile_pictures/default_profilepic.jpg'  width='20' height='20'></div>";
                            }
                        } else {
                            $path = "./profile_pictures/default_profilepic.jpg";
                            echo "<div class='float_left'><img src='$path' alt='/profile_pictures/default_profilepic.jpg'  width='20' height='20'></div>";
                        }
                        echo "&nbsp;<div class='float_right'><a id='edit' target='collabsoft' href='profilePage.php?property_variable=mine'>{$_SESSION['email']}</a>";
                        ?>
                        &nbsp;<a href="signOut.php"><?php echo $lang['sign_out']; ?></a></div>
                    </div></td>

            </tr>
            <!--<tr><td colspan="10"><div id ="bar">
            <?php
            require_once "statics.php";
            /* $news = rsSelect(array("ann_title", "ann_text"), "o_postnews_conference");
              echo "<span id='marquee'><font color='snow'>";
              if (mysql_num_rows($news) == 0) {
              echo "<strong>" . $lang['news'] . "</strong>";
              }
              while ($row = mysql_fetch_assoc($news)) {
              $ann_title = formatText_safe($row['ann_title']);
              $ann_text = formatText_safe($row['ann_text']);
              echo "<strong>{$ann_title}:</strong> {$ann_text} &nbsp;&nbsp;&nbsp; <img src='marquee.png' alt='ConfO logo'  /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
              }
              echo "</font></span>"; */
            ?>
                    </div></td></tr>-->
        </table>
        <div id="nav" class="mmenu">
            <ul id="nav_ul" class="float_left">
                <li><a class="upper" id="li1" target="collabsoft" href= "profilePage.php?property_variable=mine"><?php echo $lang['profile']; ?></a></li>
                <li><a id="li2" class="menu-message" target="collabsoft" href= "viewMessages.php"><?php echo $lang['messages']; ?>
                        &nbsp;<label id="num_msg"></label></a></li>
                <li><a id="li3" class="menu-conference"  target="collabsoft" href= "userHomepage.php"><?php echo $lang['my_conferences']; ?></a></li>
                <li><a id="li4" class="menu-conference2"  target="collabsoft" href= "availableConferences2.php"><?php echo $lang['conferences']; ?></a></li>
                <li><a id="li5" class="menu-request" target="collabsoft" href= "incomingRequests.php"><?php echo $lang['requests']; ?>
                        &nbsp;<label id="num_requests"></label></a></li>
                <li><a id="li6" class="menu-news"
                       target="collabsoft" href= "viewNews.php" ><?php echo $lang['news_2']; ?></a></li>
                <li><a class="lower" id="li7" target="collabsoft" href= "generalOptions.php" ><?php echo $lang['options']; ?></a></li>
            </ul>
        </div>
        <iframe scrolling="no" id="collabsoft" name="collabsoft" class="collabsoft"></iframe>
        <div class="footer" id="footer">
            <a target="collabsoft" href="aboutUs.php"><?php echo $lang['about_us']; ?></a> |
            <a target="collabsoft" href="termsOfService.php"><?php echo $lang['terms_ofService']; ?></a> |
            <a target="collabsoft" href="privacyPolicy.php"><?php echo $lang['policy']; ?></a>
        </div>
        <a class="top_button" href="#top" id="toplink"><?php echo $lang['go_to_top']; ?></a>
        <?php include "jquery.php" ?>
        <script type="text/javascript" src="functions.js"></script>
        <script type="text/javascript" src="resize.js"></script>
        <script type="text/javascript">
            //<![CDATA[
            function serverTime()
            {
                $.ajax({
                    type:"GET",
                    url:"time.php",
                    success:function(response)
                    {
                        $("#server_time").html("<strong>Server Date/Time:</strong>"+response);
                    }
                });
            }
            /*function animate_marquee()
            {
                var offset_right=$("#marquee").offset().left+$("#marquee").width();
                if(offset_right<=0)
                {
                    $("#marquee").css("left", $(window).width());
                }
                var offset_left=parseInt($("#marquee").css("left"))-10;
                $("#marquee").css("left",offset_left);
            }*/
            //]]>
        </script>
        <script type="text/javascript">
            //<![CDATA[
           
            $(document).ready(function()
            {
                $(".footer").css("right", ($(window).width()/2)-100);
                $.ajax ({
                    type: 'POST',
                    url:  'seen_messages.php',
                    success: function(response) {
                        if(response == "0") {
                            $("#num_msg").html('');
                            $("#num_msg").removeClass("num_msg");
                        } else {
                            $("#num_msg").html(response);
                            $("#num_msg").addClass("num_msg");
                        }
                    }
                });
                $.ajax ({
                    type: 'POST',
                    url:  'num_requests.php',
                    success: function(response) {
                        if(response == "0") {
                            $("#num_requests").html('');
                            $("#num_requests").removeClass("num_requests");
                        } else {
                            $("#num_requests").text(response);
                            $("#num_requests").addClass("num_requests");
                        }
                    }
                });
                $(window).scroll(function () { 
                    $("#nav").animate({"padding-top": $(document).scrollTop()+10},{duration:300,queue:false});
                });
                $(window).bind("beforeunload",function()
                {
                    expire=new Date();
                    expire.setTime(expire.getTime()+(10*1000));
                    expire_format="; expires="+expire.toGMTString();
                    document.cookie="frame="+$("#collabsoft").attr("src")+expire_format+"; path=/";
                });
                $(window).resize(function()
                {
                    resize_iframe();
                });
                $(window).load(function ()
                {
                    serverTime();
                    setInterval("serverTime()",60000);
                    //setInterval("animate_marquee()",100);
                    $("#collabsoft").load(function()
                    {                        
                        resize_iframe();
                        $(this).fadeIn(500,function()
                        {
                            $(this).contents().on("click","a",function(event)
                            {
                                var element=this;
                                event.preventDefault();                               
                                if($(element).attr("target")==undefined && $(element).attr("href").indexOf("#")==-1)
                                {
                                    $("#collabsoft").fadeOut(500,function()
                                    {
                                        $("#collabsoft").attr("src",$(element).attr("href"));
                                    });
                                }
                                else if($(element).attr("target")=="_blank")
                                {
                                    window.open($(this).attr("href"));
                                }
                                else if($(element).attr("target")=="_top")
                                {
                                    top.window.location=$(this).attr("href");
                                }
                                return false;
                            });
                        });
                    });
                    if($(".page").length>0)
                    {
                        query_string=$(".page").first().val()+"?";
                        $(".parameter").each(function()
                        {
                            query_string+=$(this).attr("name")+"="+$(this).val()+"&";
                        });
                        $("#collabsoft").attr("src", query_string.substr(0,query_string.length-1));
                    }
                    else if((last_frame=document.cookie.indexOf("frame"))!=-1)
                    {
                        tmp="";
                        for(i=last_frame;i<document.cookie.length;i++)
                        {
                            if(document.cookie.charAt(i)==";")
                                break;
                            else
                                tmp+=document.cookie.charAt(i);
                        }
                        value=tmp.substr(tmp.indexOf("=")+1);
                        $("#collabsoft").attr("src", value);
                    }
                    else
                        $("#collabsoft").attr("src","latestNews.php");
                    $("#nav a").click(function(event)
                    { // function to handle click events of menu anchors
                        event.preventDefault();
                        $("#collabsoft").fadeOut(500, function()
                        {
                            $("#collabsoft").attr("src",$(event.target).attr("href"));
                        });
                        return false;
                    });
                    if($(".parameter").find("input[name=start]").length>0)
                    {
                        $("#collabsoft").attr("src","conferenceSetup.php");
                    }
                    $("#collabsoft").bind("resize",function()
                    {
                        $(".footer").css("right", ($(window).width()/2)-100);
                        var elem = $(this);
                        var x =  elem.height();
                        if(x > 600) {
                            $("#footer").css("top", x+50);
                        } else {
                            $("#footer").css("top", 651);
                        }
                    });
                    if (navigator.appName == "Microsoft Internet Explorer" && ((navigator.appVersion.indexOf("MSIE 8.0")!=-1) || navigator.appVersion.indexOf("MSIE 7.0")!=-1))
                    {
                        $("head").append("<bgsound loop='1' src='test.mp3'></bgsound>");
                    }

                    $("#nav a").click(function ()
                    {
                        $('#nav a').removeClass('selected');
                        $(this).addClass('selected');
                    });
                    $vis = 1;
                    $("#bt").click(function ()
                    { // click function to show hide the menu and animate the iframe to fit the whole width of the page
                        /*if ($vis==1)
                        {
                            $vis = 0;
                            $("#nav").animate({left:'-=200px'}, 'slow');
                            $("#collabsoft").animate({width: $(window).width()*0.99}, 'slow');
                        }
                        else
                        {
                            $vis = 1;
                            $("#nav").animate({left:'+=200px'}, 'slow');
                            $("#collabsoft").animate({width: $(window).width()-$("#nav").width()}, 'slow');
                        }*/
                        $("#collabsoft").attr("src","latestNews.php");
                    });
                });
            });
            //]]>
        </script>
    </body>
</html>